include(vtkQt)

vtk_add_test_cxx(${vtk-module}CxxTests tests
  NO_VALID
  TestQtDebugLeaksView.cxx
  TestQtTableModelAdapter.cxx
  TestQtTreeModelAdapter.cxx
  )

if(VTK_QT_VERSION VERSION_GREATER "4" AND
    VTK_RENDERING_BACKEND STREQUAL "OpenGL2")
  vtk_add_test_cxx(${vtk-module}CxxTests tests
    TestQVTKOpenGLWidget.cxx
    TestQVTKOpenGLWidgetWithDisabledInteractor.cxx
    TestQVTKOpenGLWidgetWithMSAA.cxx
    )
  vtk_add_test_cxx(${vtk-module}CxxTests tests
    NO_VALID
    TestQVTKOpenGLWidgetPicking.cxx
    )
endif()

if(NOT VTK_LEGACY_REMOVE)
  # tests use legacy QVTKWidget.
  if(WIN32)
    vtk_add_test_cxx(${vtk-module}CxxTests tests
      NO_VALID
      TestWin32QVTKWidget.cxx)
  endif()
  vtk_add_test_cxx(${vtk-module}CxxTests tests
    NO_VALID
    TestQtSwapWindows.cxx)
endif()

if(VTK_QT_VERSION VERSION_GREATER "4")
  find_package(Qt5 COMPONENTS Widgets REQUIRED)
  include_directories(${Qt5Widgets_INCLUDE_DIRS})
  add_definitions(${Qt5Widgets_DEFINITIONS})
else()
  find_package(Qt4 REQUIRED)
  include(${QT_USE_FILE})
endif()

vtk_test_cxx_executable(${vtk-module}CxxTests tests
  QTestApp.cxx)

if(VTK_QT_VERSION VERSION_GREATER "4")
  set_target_properties(${vtk-module}CxxTests PROPERTIES
    COMPILE_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
endif()
